
    if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FK5EFCD9CF7497FBFF]') AND parent_object_id = OBJECT_ID('UserToProject_Coordinator'))
alter table UserToProject_Coordinator  drop constraint FK5EFCD9CF7497FBFF


    if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FK5EFCD9CF72E30826]') AND parent_object_id = OBJECT_ID('UserToProject_Coordinator'))
alter table UserToProject_Coordinator  drop constraint FK5EFCD9CF72E30826


    if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FK651459D17497FBFF]') AND parent_object_id = OBJECT_ID('UserToProject_Member'))
alter table UserToProject_Member  drop constraint FK651459D17497FBFF


    if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FK651459D172E30826]') AND parent_object_id = OBJECT_ID('UserToProject_Member'))
alter table UserToProject_Member  drop constraint FK651459D172E30826


    if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FK9C29058EE5E5DF4F]') AND parent_object_id = OBJECT_ID('KeywordToProject'))
alter table KeywordToProject  drop constraint FK9C29058EE5E5DF4F


    if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FK9C29058E72E30826]') AND parent_object_id = OBJECT_ID('KeywordToProject'))
alter table KeywordToProject  drop constraint FK9C29058E72E30826


    if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FKA533F1F418FF90DA]') AND parent_object_id = OBJECT_ID('[Specimen]'))
alter table [Specimen]  drop constraint FKA533F1F418FF90DA


    if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FKA533F1F4DE3B1469]') AND parent_object_id = OBJECT_ID('[Specimen]'))
alter table [Specimen]  drop constraint FKA533F1F4DE3B1469


    if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FKBBF6E8D572E30826]') AND parent_object_id = OBJECT_ID('[Occurrence]'))
alter table [Occurrence]  drop constraint FKBBF6E8D572E30826


    if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FKBBF6E8D5447FE1A8]') AND parent_object_id = OBJECT_ID('[Occurrence]'))
alter table [Occurrence]  drop constraint FKBBF6E8D5447FE1A8


    if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FKBBF6E8D57497FBFF]') AND parent_object_id = OBJECT_ID('[Occurrence]'))
alter table [Occurrence]  drop constraint FKBBF6E8D57497FBFF


    if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FKBBF6E8D5DF79B871]') AND parent_object_id = OBJECT_ID('[Occurrence]'))
alter table [Occurrence]  drop constraint FKBBF6E8D5DF79B871


    if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FKBBF6E8D541BE8C54]') AND parent_object_id = OBJECT_ID('[Occurrence]'))
alter table [Occurrence]  drop constraint FKBBF6E8D541BE8C54


    if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FKBBF6E8D5A3D85856]') AND parent_object_id = OBJECT_ID('[Occurrence]'))
alter table [Occurrence]  drop constraint FKBBF6E8D5A3D85856


    if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FKBBF6E8D514431E30]') AND parent_object_id = OBJECT_ID('[Occurrence]'))
alter table [Occurrence]  drop constraint FKBBF6E8D514431E30


    if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FK43FD3B39DD790364]') AND parent_object_id = OBJECT_ID('EcosystemToOccurrence'))
alter table EcosystemToOccurrence  drop constraint FK43FD3B39DD790364


    if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FK43FD3B3918FF90DA]') AND parent_object_id = OBJECT_ID('EcosystemToOccurrence'))
alter table EcosystemToOccurrence  drop constraint FK43FD3B3918FF90DA


    if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FKFE44CB7D9E1119D5]') AND parent_object_id = OBJECT_ID('HabitatToOccurrence'))
alter table HabitatToOccurrence  drop constraint FKFE44CB7D9E1119D5


    if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FKFE44CB7D18FF90DA]') AND parent_object_id = OBJECT_ID('HabitatToOccurrence'))
alter table HabitatToOccurrence  drop constraint FKFE44CB7D18FF90DA


    if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FK3D99E1A6BA511695]') AND parent_object_id = OBJECT_ID('MicroHabitatToOccurrence'))
alter table MicroHabitatToOccurrence  drop constraint FK3D99E1A6BA511695


    if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FK3D99E1A618FF90DA]') AND parent_object_id = OBJECT_ID('MicroHabitatToOccurrence'))
alter table MicroHabitatToOccurrence  drop constraint FK3D99E1A618FF90DA


    if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FKB51205C8E5E5DF4F]') AND parent_object_id = OBJECT_ID('KeywordToOccurrence'))
alter table KeywordToOccurrence  drop constraint FKB51205C8E5E5DF4F


    if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FKB51205C818FF90DA]') AND parent_object_id = OBJECT_ID('KeywordToOccurrence'))
alter table KeywordToOccurrence  drop constraint FKB51205C818FF90DA


    if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FK50721A0B7A193720]') AND parent_object_id = OBJECT_ID('OccurrenceToOccurrence'))
alter table OccurrenceToOccurrence  drop constraint FK50721A0B7A193720


    if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FK50721A0B4203D8F1]') AND parent_object_id = OBJECT_ID('OccurrenceToOccurrence'))
alter table OccurrenceToOccurrence  drop constraint FK50721A0B4203D8F1


    if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FK2879C03A80E1A96A]') AND parent_object_id = OBJECT_ID('[DepositaryUnitRecord]'))
alter table [DepositaryUnitRecord]  drop constraint FK2879C03A80E1A96A


    if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FK2879C03A4A52BD9D]') AND parent_object_id = OBJECT_ID('[DepositaryUnitRecord]'))
alter table [DepositaryUnitRecord]  drop constraint FK2879C03A4A52BD9D


    if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FKA9354A22CB47568A]') AND parent_object_id = OBJECT_ID('[Taxon]'))
alter table [Taxon]  drop constraint FKA9354A22CB47568A


    if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FKA9354A223640B4E6]') AND parent_object_id = OBJECT_ID('[Taxon]'))
alter table [Taxon]  drop constraint FKA9354A223640B4E6


    if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FK2FE121BE8747976D]') AND parent_object_id = OBJECT_ID('[Location]'))
alter table [Location]  drop constraint FK2FE121BE8747976D


    if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FK2FE121BE53768472]') AND parent_object_id = OBJECT_ID('[Location]'))
alter table [Location]  drop constraint FK2FE121BE53768472


    if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FK2FE121BE2703114D]') AND parent_object_id = OBJECT_ID('[Location]'))
alter table [Location]  drop constraint FK2FE121BE2703114D


    if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FK7E2B3718B78996C2]') AND parent_object_id = OBJECT_ID('[OccurrenceAuthor]'))
alter table [OccurrenceAuthor]  drop constraint FK7E2B3718B78996C2


    if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FK76403652703114D]') AND parent_object_id = OBJECT_ID('[Municipality]'))
alter table [Municipality]  drop constraint FK76403652703114D


    if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FKD823081E5F2F8F41]') AND parent_object_id = OBJECT_ID('[TaxonomicClassification]'))
alter table [TaxonomicClassification]  drop constraint FKD823081E5F2F8F41


    if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FKD823081EB63C6163]') AND parent_object_id = OBJECT_ID('[TaxonomicClassification]'))
alter table [TaxonomicClassification]  drop constraint FKD823081EB63C6163


    if exists (select * from dbo.sysobjects where id = object_id(N'[Project]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [Project]

    if exists (select * from dbo.sysobjects where id = object_id(N'UserToProject_Coordinator') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table UserToProject_Coordinator

    if exists (select * from dbo.sysobjects where id = object_id(N'UserToProject_Member') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table UserToProject_Member

    if exists (select * from dbo.sysobjects where id = object_id(N'KeywordToProject') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table KeywordToProject

    if exists (select * from dbo.sysobjects where id = object_id(N'[User]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [User]

    if exists (select * from dbo.sysobjects where id = object_id(N'[Specimen]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [Specimen]

    if exists (select * from dbo.sysobjects where id = object_id(N'[Publication]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [Publication]

    if exists (select * from dbo.sysobjects where id = object_id(N'[TaxonReference]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [TaxonReference]

    if exists (select * from dbo.sysobjects where id = object_id(N'[Method]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [Method]

    if exists (select * from dbo.sysobjects where id = object_id(N'[Log]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [Log]

    if exists (select * from dbo.sysobjects where id = object_id(N'[Occurrence]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [Occurrence]

    if exists (select * from dbo.sysobjects where id = object_id(N'EcosystemToOccurrence') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table EcosystemToOccurrence

    if exists (select * from dbo.sysobjects where id = object_id(N'HabitatToOccurrence') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table HabitatToOccurrence

    if exists (select * from dbo.sysobjects where id = object_id(N'MicroHabitatToOccurrence') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table MicroHabitatToOccurrence

    if exists (select * from dbo.sysobjects where id = object_id(N'KeywordToOccurrence') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table KeywordToOccurrence

    if exists (select * from dbo.sysobjects where id = object_id(N'OccurrenceToOccurrence') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table OccurrenceToOccurrence

    if exists (select * from dbo.sysobjects where id = object_id(N'[DepositaryUnitRecord]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [DepositaryUnitRecord]

    if exists (select * from dbo.sysobjects where id = object_id(N'[Taxon]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [Taxon]

    if exists (select * from dbo.sysobjects where id = object_id(N'[Ecosystem]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [Ecosystem]

    if exists (select * from dbo.sysobjects where id = object_id(N'[Institution]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [Institution]

    if exists (select * from dbo.sysobjects where id = object_id(N'[ConservationUnit]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [ConservationUnit]

    if exists (select * from dbo.sysobjects where id = object_id(N'[AquaticData]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [AquaticData]

    if exists (select * from dbo.sysobjects where id = object_id(N'[Location]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [Location]

    if exists (select * from dbo.sysobjects where id = object_id(N'[DrainageBasin]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [DrainageBasin]

    if exists (select * from dbo.sysobjects where id = object_id(N'[DepositaryUnit]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [DepositaryUnit]

    if exists (select * from dbo.sysobjects where id = object_id(N'[MicroHabitat]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [MicroHabitat]

    if exists (select * from dbo.sysobjects where id = object_id(N'[OccurrenceAuthor]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [OccurrenceAuthor]

    if exists (select * from dbo.sysobjects where id = object_id(N'[Municipality]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [Municipality]

    if exists (select * from dbo.sysobjects where id = object_id(N'[Habitat]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [Habitat]

    if exists (select * from dbo.sysobjects where id = object_id(N'[Keyword]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [Keyword]

    if exists (select * from dbo.sysobjects where id = object_id(N'[LegacyTaxonomicGroup]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [LegacyTaxonomicGroup]

    if exists (select * from dbo.sysobjects where id = object_id(N'[TaxonomicClassification]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [TaxonomicClassification]

    create table [Project] (
        Id INT not null,
       Version INT not null,
       Name NVARCHAR(256) not null,
       Objectives NVARCHAR(MAX) null,
       TeamDescription NVARCHAR(MAX) null,
       ParticipatingInstitutions NVARCHAR(MAX) null,
       ExpectedProducts NVARCHAR(MAX) null,
       ProjectStatus NVARCHAR(20) null,
       WebsiteURL NVARCHAR(128) null,
       StartDate NVARCHAR(255) null,
       EndDate NVARCHAR(255) null,
       FAPESPProject BIT null,
       Biome NVARCHAR(800) null,
       Abstract NVARCHAR(MAX) null,
       primary key (Id)
    )

    create table UserToProject_Coordinator (
        Project_id INT not null,
       User_id INT not null
    )

    create table UserToProject_Member (
        Project_id INT not null,
       User_id INT not null
    )

    create table KeywordToProject (
        Project_id INT not null,
       Keyword_id INT not null
    )

    create table [User] (
        Id INT not null,
       Version INT not null,
       Name NVARCHAR(128) not null,
       Address NVARCHAR(1000) null,
       PhoneNumber NVARCHAR(50) null,
       FaxNumber NVARCHAR(30) null,
       Username NVARCHAR(50) not null,
       Password NVARCHAR(50) not null,
       PasswordSalt NVARCHAR(50) not null,
       Email NVARCHAR(128) not null,
       Comment NVARCHAR(MAX) null,
       Note NVARCHAR(MAX) null,
       PasswordQuestion NVARCHAR(100) null,
       FailedPasswordAttemptCount INT null,
       PasswordAnswer NVARCHAR(100) null,
       IsApproved BIT not null,
       IsLockedOut BIT not null,
       IsOnline BIT not null,
       CreationDate DATETIME not null,
       LastLoginDate DATETIME not null,
       LastActivityDate DATETIME not null,
       LastLockedOutDate DATETIME not null,
       LastPasswordChangedDate DATETIME not null,
       Role NVARCHAR(20) not null,
       primary key (Id)
    )

    create table [Specimen] (
        Id INT not null,
       Version INT not null,
       Occurrence_id INT null,
       TaxonomicClassification_id INT null,
       primary key (Id)
    )

    create table [Publication] (
        Id INT not null,
       Version INT not null,
       Title NVARCHAR(1000) not null,
       Journal NVARCHAR(255) null,
       Number NVARCHAR(255) null,
       Abstract NVARCHAR(255) null,
       primary key (Id)
    )

    create table [TaxonReference] (
        Id INT not null,
       Version INT not null,
       Title NVARCHAR(512) not null,
       primary key (Id)
    )

    create table [Method] (
        Id INT not null,
       Version INT not null,
       Name NVARCHAR(500) not null,
       Description NVARCHAR(1000) null,
       primary key (Id)
    )

    create table [Log] (
        Id INT IDENTITY NOT NULL,
       Date DATETIME not null,
       Thread NVARCHAR(255) not null,
       Level NVARCHAR(50) not null,
       Logger NVARCHAR(255) not null,
       AuthUser NVARCHAR(50) null,
       Message NVARCHAR(4000) not null,
       Exception NVARCHAR(2000) not null,
       primary key (Id)
    )

    create table [Occurrence] (
        Id INT not null,
       Version INT not null,
       StartDate NVARCHAR(12) null,
       EndDate NVARCHAR(12) null,
       UncertainInformation BIT null,
       FinalRemarks NVARCHAR(MAX) null,
       OpenAccessDate NVARCHAR(12) null,
       RecordDate NVARCHAR(12) null,
       LastUpdateDate NVARCHAR(12) null,
       Project_id INT not null,
       Author_id INT not null,
       User_id INT null,
       BibliographicalReference_id INT null,
       Location_id INT null,
       AquaticData_id INT null,
       Method_id INT null,
       primary key (Id)
    )

    create table EcosystemToOccurrence (
        Occurrence_id INT not null,
       Ecosystem_id INT not null
    )

    create table HabitatToOccurrence (
        Occurrence_id INT not null,
       Habitat_id INT not null
    )

    create table MicroHabitatToOccurrence (
        Occurrence_id INT not null,
       MicroHabitat_id INT not null
    )

    create table KeywordToOccurrence (
        Occurrence_id INT not null,
       Keyword_id INT not null
    )

    create table OccurrenceToOccurrence (
        Occurrence1_Id INT not null,
       Occurrence2_Id INT not null
    )

    create table [DepositaryUnitRecord] (
        Id INT not null,
       Version INT not null,
       UniqueId NVARCHAR(255) null,
       DepositaryUnit_id INT null,
       Specimen_id INT null,
       primary key (Id)
    )

    create table [Taxon] (
        Id INT IDENTITY NOT NULL,
       Version INT not null,
       Name NVARCHAR(255) null,
       Rank NVARCHAR(255) null,
       Parent_id INT null,
       TaxonReference_id INT null,
       primary key (Id)
    )

    create table [Ecosystem] (
        Id INT IDENTITY NOT NULL,
       Version INT not null,
       Name NVARCHAR(255) null,
       Ordering INT null,
       primary key (Id)
    )

    create table [Institution] (
        Id INT IDENTITY NOT NULL,
       Version INT not null,
       Name NVARCHAR(255) null,
       Address NVARCHAR(255) null,
       primary key (Id)
    )

    create table [ConservationUnit] (
        Id INT IDENTITY NOT NULL,
       Version INT not null,
       Name NVARCHAR(255) null,
       Category NVARCHAR(255) null,
       IdWCMC INT null,
       Jurisdiction NVARCHAR(255) null,
       YearOfCreation INT null,
       primary key (Id)
    )

    create table [AquaticData] (
        Id INT IDENTITY NOT NULL,
       Version INT not null,
       Temperature DOUBLE PRECISION null,
       Conductivity DOUBLE PRECISION null,
       DissolvedOxygen DOUBLE PRECISION null,
       pH DOUBLE PRECISION null,
       SecchiDepth DOUBLE PRECISION null,
       Turbidity DOUBLE PRECISION null,
       RiverOrder DOUBLE PRECISION null,
       Salinity DOUBLE PRECISION null,
       primary key (Id)
    )

    create table [Location] (
        Id INT IDENTITY NOT NULL,
       Version INT not null,
       Ambient NVARCHAR(255) null,
       Description NVARCHAR(255) null,
       Latitude DOUBLE PRECISION null,
       Longitude DOUBLE PRECISION null,
       LocationExtension NVARCHAR(255) null,
       LocationExtensionUnit NVARCHAR(255) null,
       LocationPrecision NVARCHAR(255) null,
       GPSPrecision REAL null,
       ConservationUnit_id INT null,
       Municipality_id INT null,
       DrainageBasin_id INT null,
       primary key (Id)
    )

    create table [DrainageBasin] (
        Id INT IDENTITY NOT NULL,
       Version INT not null,
       Name NVARCHAR(255) null,
       primary key (Id)
    )

    create table [DepositaryUnit] (
        Id INT IDENTITY NOT NULL,
       Version INT not null,
       Name NVARCHAR(255) null,
       primary key (Id)
    )

    create table [MicroHabitat] (
        Id INT IDENTITY NOT NULL,
       Version INT not null,
       Name NVARCHAR(255) null,
       Ordering INT null,
       primary key (Id)
    )

    create table [OccurrenceAuthor] (
        Id INT IDENTITY NOT NULL,
       Version INT not null,
       Name NVARCHAR(255) null,
       Address NVARCHAR(255) null,
       PhoneNumber NVARCHAR(255) null,
       FaxNumber NVARCHAR(255) null,
       Email NVARCHAR(255) null,
       Institution_id INT null,
       primary key (Id)
    )

    create table [Municipality] (
        Id INT IDENTITY NOT NULL,
       Version INT not null,
       Name NVARCHAR(255) null,
       State NVARCHAR(255) null,
       DrainageBasin_id INT null,
       primary key (Id)
    )

    create table [Habitat] (
        Id INT IDENTITY NOT NULL,
       Version INT not null,
       Name NVARCHAR(255) null,
       Ordering INT null,
       primary key (Id)
    )

    create table [Keyword] (
        Id INT IDENTITY NOT NULL,
       Version INT not null,
       Name NVARCHAR(255) null,
       primary key (Id)
    )

    create table [LegacyTaxonomicGroup] (
        Id INT IDENTITY NOT NULL,
       Version INT not null,
       Name NVARCHAR(255) null,
       LegacyTaxonomicClassification NVARCHAR(255) null,
       RequiredRanks NVARCHAR(255) null,
       primary key (Id)
    )

    create table [TaxonomicClassification] (
        Id INT IDENTITY NOT NULL,
       Version INT not null,
       EOLTaxonId NVARCHAR(255) null,
       LegacyTaxonomicClassification NVARCHAR(255) null,
       Taxon_id INT null,
       LegacyTaxonomicGroup_id INT null,
       primary key (Id)
    )

    alter table UserToProject_Coordinator 
        add constraint FK5EFCD9CF7497FBFF 
        foreign key (User_id) 
        references [User]

    alter table UserToProject_Coordinator 
        add constraint FK5EFCD9CF72E30826 
        foreign key (Project_id) 
        references [Project]

    alter table UserToProject_Member 
        add constraint FK651459D17497FBFF 
        foreign key (User_id) 
        references [User]

    alter table UserToProject_Member 
        add constraint FK651459D172E30826 
        foreign key (Project_id) 
        references [Project]

    alter table KeywordToProject 
        add constraint FK9C29058EE5E5DF4F 
        foreign key (Keyword_id) 
        references [Keyword]

    alter table KeywordToProject 
        add constraint FK9C29058E72E30826 
        foreign key (Project_id) 
        references [Project]

    alter table [Specimen] 
        add constraint FKA533F1F418FF90DA 
        foreign key (Occurrence_id) 
        references [Occurrence]

    alter table [Specimen] 
        add constraint FKA533F1F4DE3B1469 
        foreign key (TaxonomicClassification_id) 
        references [TaxonomicClassification]

    alter table [Occurrence] 
        add constraint FKBBF6E8D572E30826 
        foreign key (Project_id) 
        references [Project]

    alter table [Occurrence] 
        add constraint FKBBF6E8D5447FE1A8 
        foreign key (Author_id) 
        references [OccurrenceAuthor]

    alter table [Occurrence] 
        add constraint FKBBF6E8D57497FBFF 
        foreign key (User_id) 
        references [User]

    alter table [Occurrence] 
        add constraint FKBBF6E8D5DF79B871 
        foreign key (BibliographicalReference_id) 
        references [Publication]

    alter table [Occurrence] 
        add constraint FKBBF6E8D541BE8C54 
        foreign key (Location_id) 
        references [Location]

    alter table [Occurrence] 
        add constraint FKBBF6E8D5A3D85856 
        foreign key (AquaticData_id) 
        references [AquaticData]

    alter table [Occurrence] 
        add constraint FKBBF6E8D514431E30 
        foreign key (Method_id) 
        references [Method]

    alter table EcosystemToOccurrence 
        add constraint FK43FD3B39DD790364 
        foreign key (Ecosystem_id) 
        references [Ecosystem]

    alter table EcosystemToOccurrence 
        add constraint FK43FD3B3918FF90DA 
        foreign key (Occurrence_id) 
        references [Occurrence]

    alter table HabitatToOccurrence 
        add constraint FKFE44CB7D9E1119D5 
        foreign key (Habitat_id) 
        references [Habitat]

    alter table HabitatToOccurrence 
        add constraint FKFE44CB7D18FF90DA 
        foreign key (Occurrence_id) 
        references [Occurrence]

    alter table MicroHabitatToOccurrence 
        add constraint FK3D99E1A6BA511695 
        foreign key (MicroHabitat_id) 
        references [MicroHabitat]

    alter table MicroHabitatToOccurrence 
        add constraint FK3D99E1A618FF90DA 
        foreign key (Occurrence_id) 
        references [Occurrence]

    alter table KeywordToOccurrence 
        add constraint FKB51205C8E5E5DF4F 
        foreign key (Keyword_id) 
        references [Keyword]

    alter table KeywordToOccurrence 
        add constraint FKB51205C818FF90DA 
        foreign key (Occurrence_id) 
        references [Occurrence]

    alter table OccurrenceToOccurrence 
        add constraint FK50721A0B7A193720 
        foreign key (Occurrence2_Id) 
        references [Occurrence]

    alter table OccurrenceToOccurrence 
        add constraint FK50721A0B4203D8F1 
        foreign key (Occurrence1_Id) 
        references [Occurrence]

    alter table [DepositaryUnitRecord] 
        add constraint FK2879C03A80E1A96A 
        foreign key (DepositaryUnit_id) 
        references [DepositaryUnit]

    alter table [DepositaryUnitRecord] 
        add constraint FK2879C03A4A52BD9D 
        foreign key (Specimen_id) 
        references [Specimen]

    alter table [Taxon] 
        add constraint FKA9354A22CB47568A 
        foreign key (Parent_id) 
        references [Taxon]

    alter table [Taxon] 
        add constraint FKA9354A223640B4E6 
        foreign key (TaxonReference_id) 
        references [TaxonReference]

    alter table [Location] 
        add constraint FK2FE121BE8747976D 
        foreign key (ConservationUnit_id) 
        references [ConservationUnit]

    alter table [Location] 
        add constraint FK2FE121BE53768472 
        foreign key (Municipality_id) 
        references [Municipality]

    alter table [Location] 
        add constraint FK2FE121BE2703114D 
        foreign key (DrainageBasin_id) 
        references [DrainageBasin]

    alter table [OccurrenceAuthor] 
        add constraint FK7E2B3718B78996C2 
        foreign key (Institution_id) 
        references [Institution]

    alter table [Municipality] 
        add constraint FK76403652703114D 
        foreign key (DrainageBasin_id) 
        references [DrainageBasin]

    alter table [TaxonomicClassification] 
        add constraint FKD823081E5F2F8F41 
        foreign key (Taxon_id) 
        references [Taxon]

    alter table [TaxonomicClassification] 
        add constraint FKD823081EB63C6163 
        foreign key (LegacyTaxonomicGroup_id) 
        references [LegacyTaxonomicGroup]
